<?php

namespace App\Models\Base;
use App\Models\BaseModel;

/**
 * 全国行政划分模型类
 *
 * @package App\Models
 * @author WangBin
 * @date 2021-06-11
 */
class Regions extends BaseModel
{
    protected $table = 'base_regions';
    protected $primaryKey = 'region_id';

    /**
     * 保存数据
     *
     * @param array $data
     * @return mixed
     */
    public static function saveData(array $data)
    {
        $query = new Regions();
        collect($data)->each(function ($value, $field) use ($query){
            $query->{$field} = $value;
        });
        return $query->save() ? $query->region_id : 0;
    }
}
